package com.easyedu.core.dao;

import com.easyedu.core.entity.po.CultivationScheme;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * @author lmr
 **/
@Mapper
public interface CultivationSchemeDao {

     /**
      * 功能描述:通过课程表新建培养方案表
      *
      * @param cultivationNumber    1 培养方案序号
      * @param cultivationName      2 培养方案名称
      * @param belongInstituteId    3 培养方案所属学院id
      * @param belongInstituteName  4 培养方案所属学院名称
      * @param belongDepartmentId   5 培养方案所属专业id
      * @param belongDepartmentName 6 培养方案所属专业名称
      * @param grade                7 年级
      * @param schoolYear           8 学年
      * @param semester             9 学期
      * @param theoryClassHour      10 理论学时
      * @param experimentClassHour  11 实践学时
      * @param totalClassHour       12 总学时
      * @param usualScoreRatio      13 平时成绩占比
      * @param experimentScoreRatio 14 实践成绩占比
      * @param examScoreRatio       15 总成绩占比
      * @param note                 16 备注
      * @param courseId             17 课程id
      * @return : java.lang.Integer
      **/
     @Insert("insert into cultivation_scheme(cultivation_number, cultivation_name, belong_institute_id, "
             + "belong_institute_name, belong_department_id, belong_department_name, grade, school_year, semester, "
             + "course_id, open_institute_id, open_institute_name, course_code, course_name, course_nature, "
             + "have_in_class_experiment, examination_method, credit, grade_type, theory_class_hour, "
             + "experiment_class_hour, total_class_hour, usual_score_ratio, experiment_score_ratio, exam_score_ratio, "
             + "note, create_time, update_time) SELECT #{cultivationNumber}, #{cultivationName}, "
             + "#{belongInstituteId}, #{belongInstituteName},#{belongDepartmentId}, #{belongDepartmentName}, "
             + "#{grade},#{schoolYear},#{semester},course_id,open_institute_id,open_institute_name,course_code,"
             + "course_name,course_nature,have_in_class_experiment,examination_method,credit,grade_type,"
             + "#{theoryClassHour},#{experimentClassHour},#{totalClassHour},#{usualScoreRatio},"
             + "#{experimentScoreRatio},#{examScoreRatio},#{note},NOW(),NOW() from course where course_id = "
             + "#{courseId}")
     Integer createCultivationScheme(String cultivationNumber, String cultivationName, long belongInstituteId,
             String belongInstituteName, long belongDepartmentId, String belongDepartmentName, String grade,
             String schoolYear, String semester, long theoryClassHour, long experimentClassHour, long totalClassHour,
             double usualScoreRatio, double experimentScoreRatio, double examScoreRatio, String note, long courseId);

     /**
      * 功能描述:通过id获取培养计划表信息
      *
      * @param cultivationSchemeId 1 培养方案id
      * @return : com.easyedu.api.entity.DO.CultivationScheme
      **/
     @Select("select * from cultivation_scheme where cultivation_scheme_id = #{cultivationSchemeId}")
     CultivationScheme getById(long cultivationSchemeId);

     /**
      * 功能描述:根据培养计划序号获取培养计划
      *
      * @param cultivationNumber 1 培养方案序号
      * @return : java.util.List<com.easyedu.api.entity.DO.CultivationScheme>
      **/
     @Select("select * from cultivation_scheme where cultivation_number = #{cultivationNumber}")
     List<CultivationScheme> getCultivationSchemeCourse(String cultivationNumber);

     /**
      * 功能描述: 根据年级,获取查询培养方案序号，培养方案名称，培养方案所属学院id，培养方案所属学院名称，年级</br>
      *
      * @param grade 1 年级
      * @return : java.util.List<com.easyedu.api.entity.DO.CultivationScheme>
      **/
     @Select("select cultivation_number,cultivation_name,belong_institute_id,belong_institute_name,"
             + "belong_department_id,belong_department_name,grade from cultivation_scheme where  grade = #{grade} "
             + "group by cultivation_number,cultivation_name,belong_institute_id,belong_institute_name,"
             + "belong_department_id,belong_department_name,grade")
     List<CultivationScheme> getCultivationScheme(String grade);

     /**
      * 根据名称查询培养方案信息
      *
      * @param cultivationNumber
      * @return 培养方案信息
      */
     @Select("select * from cultivation_scheme where cultivation_name = #{cultivationNumber}")
     List<CultivationScheme> getCultivationSchemeByNumber(String cultivationNumber);
}
